<!--
 * @Author: zhangxiangsheng 1026583651@qq.com
 * @Date: 2024-06-17 15:04:34
 * @LastEditors: zhangxiangsheng 1026583651@qq.com
 * @LastEditTime: 2024-06-25 08:42:36
 * @FilePath: \appGly\components\formz\components\forminput.vue
 * @Description: 
 * 
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
-->
<template>
  <view class="">
    <!-- {{ item }} -->
    <u-form-item :label="item.label" :prop="item.value" borderBottom>
      <u--input
        placeholder="请输入内容"
        v-model="inputValue"
        border="none"
        @blur="blur"
        :type="item.type || ''"
        v-bind="item.attrs"
      ></u--input>
      <view class="dw" v-if="item.dw">
        {{ item.dw }}
      </view>
    </u-form-item>
  </view>
</template>

<script>
  export default {
    props: {
      item: {
        typeof: Object,
        default: () => {
          return {};
        },
      },
      data: {
        typeof: Object,
        default: () => {
          return {};
        },
      },
      value: {
        typeof: [String, Number, Boolean, Array, Object],
        default: () => {
          return "";
        },
      },
    },
    data() {
      return {
        // inputValue: "",
      };
    },
    computed: {
      fl() {
        if (this.item.fl) {
          return this.item.fl;
        }
        return false;
      },
      inputValue: {
        get() {
          if (!this.item.value) {
            return this.item.defaultValue;
          }
          if (this.fl) {
            return Number(this.value).div(this.fl);
          }
          return this.value;
        },
        set(v) {
          if (this.fl) {
            v = parseInt(Number(v).mul(this.fl));
          }
          this.$emit("input", v);
        },
      },
    },
    watch: {
      // value() {
      //   this.inputValue = this.value;
      // },
    },
    methods: {
      blur() {
        // this.$emit("input", this.inputValue);
      },
    },
  };
</script>

<style lang="scss">
  .dw {
    color: #2093f5;
  }
</style>
